package com.woniu.adopt_web.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.adopt_web.entity.Activity;
import com.woniu.adopt_web.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("activity")
public class ActivityController {

    @Autowired
    private ActivityService activityService;

    @RequestMapping("/list")
    public String list(@RequestParam(value = "now" ,defaultValue = "1")Integer now ,
                       @RequestParam(value = "size" ,defaultValue = "3")Integer size,
                       Model model){
        PageInfo<Activity> ActivityPageInfo = activityService.queryAllByPage(now,size);
        System.out.println(ActivityPageInfo+"     ---------------------");
        model.addAttribute("pageActivity",ActivityPageInfo);
        System.out.println(model+"  ========================");
        return "activity";
    }



}
